<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<div align="right">
<?php 
        
    if(sizeof($diff) > 0){
        $count = 0;
        sort($diff);
		echo '<table width="225" border="0">
		  		<tr>
					<td colspan="2" bgcolor="#F8F8F8"><div align="center" class="style1"><b>Documentos Pendentes</b></div></div></td>
			   </tr>';

        while($count < sizeof($diff)){
           
            $tipoDocPendente = $this->em->find('models\tipo_documento',$diff[$count]);
			$count++;
			echo '<tr class="style1" style="background-color:#FFFFCC">
				<td width="57" align="center">'.$count.'</td>
				<td width="158">'.utf8_encode($tipoDocPendente->getTipoDocDesc()).'</td>
			 </tr>';
           
        }
        echo '</table>';
    }
?>
</div>
<form id="frmDocRegistrados">
<div align="left">
    <p id="addDocumento" align="left" style="font-size: 12px; font-weight: bold">
            <a href="#" id="lnkAddDoc">
                <img id="imgAddDoc" alt="" src="<?php echo base_url() . 'assets/images/add_doc.jpg' ?>" border="0" title="Add Documento" onclick="novoDocumento(<?= $alunoId ?>)" width="30" height="30"/>
            </a>Novo Documento
        </p>
</div>
<?php
    $exibeItem = (sizeof($documetacaoList->getResult()) > 0) ? 'block' : 'none';
?>
<br />
<div id="docCadastrado">
<fieldset id="tituloDoc" style="width:auto; display: <?= $exibeItem ?>; background-color:#FFFFFF ">
<legend><b>Documentos registrados</b></legend>
<?php 

    foreach ($documetacaoList->getResult() as $key=>$valueDoc) {
        
        $tipoDoc = $this->em->find('models\tipo_documento',$valueDoc->getTipoDocCod());
        
        $background = ($key%2==0) ? 'style="background-color:#F6F6F6"' : 'style="background-color:#FFFFCC"'; 
        
        if($tipoDoc->getGrupo() == 1){
          unset($dtExp);
          
          $ufGrupo1 = $this->em->find('models\uf',$valueDoc->getUfCod());
          
          $dtExp = explode('-',@$valueDoc->getDataEmissao());
          $dtExp = $dtExp[2].'/'.$dtExp[1].'/'.$dtExp[0];
?>

<table width="790" height="52" border="1" cellspacing="0" <?= $background?>>
<tr class="expand_head" id="tr1_doc_<?= @$valueDoc->getDocumentoId()?>">
				<td width="66" rowspan="2"><div align="center"><?= $key+1 ?></div></td>
                <td width="163"><b><?= utf8_encode($tipoDoc->getTipoDocDesc()) ?></b></td>
                <td colspan="3"><div align="left">Descri&ccedil;&atilde;o:
                    <input type="text" id="descricaoCert<?= @$valueDoc->getDocumentoId() ?>2" size="40" maxlength="40" value="<?= utf8_encode(@$valueDoc->getDocDescricao()) ?>" />
                </div>                </td>
<td><div align="right">
                  <div align="left">Data Exp:
                    <input type="text" id="dataExpCert<?= @$valueDoc->getDocumentoId() ?>3" class="datepicker" size="10" maxlength="10" value="<?= @$dtExp ?>" />
                  </div>
                </div>                  </td>
      </tr>
              <tr>
                <td><div align="left">Expedidor:
                  <input type="text" id="expedidorCert<?= @$valueDoc->getDocumentoId() ?>2" size="10" maxlength="10" value="<?= @$valueDoc->getEmissor() ?>" />
                </div>                </td>
                <td><div align="left">UF:
                  <select name="ufCert<?= @$valueDoc->getDocumentoId() ?>" id="ufCert<?= @$valueDoc->getDocumentoId() ?>2">
                    <option value="<?= $valueDoc->getUfCod() ?>">
                    <?= $ufGrupo1->getUfSigla() ?>
                    </option>
                    <?php $this->load->view('uf/cbo_uf'); ?>
                  </select>
                </div>                </td>
                <td><div align="left">Termo:
                  <input type="text" id="termoCert<?= @$valueDoc->getDocumentoId() ?>3" size="5" maxlength="5" value="<?= @$valueDoc->getTermo() ?>" />
                </div>                </td>
                <td><div align="left">Folha:
                  <input type="text" id="folhaCert<?= @$valueDoc->getDocumentoId() ?>2" size="5" maxlength="5"  value="<?= @$valueDoc->getFolha() ?>"/>
                </div>                </td>
                <td><div align="left">Livro:
                  <input type="text" id="livroCert<?= @$valueDoc->getDocumentoId() ?>2" size="5" maxlength="5" value="<?= @$valueDoc->getLivro() ?>" />
                </div>                </td>
              </tr>
    </table>
      
<?php
        } else if($tipoDoc->getGrupo() == 2){
            unset($dtExp);
            $ufGrupo2 = $this->em->find('models\uf',$valueDoc->getUfCod());
            
            $dtExp = explode('-',@$valueDoc->getDataEmissao());
            $dtExp = $dtExp[2].'/'.$dtExp[1].'/'.$dtExp[0];
           
 ?>
<table width="790" border="1" cellspacing="0" <?= $background?>>
              <tr class="expand_head" id="tr3_doc_<?= @$valueDoc->getDocumentoId()?>">
                <td width="66" rowspan="2"><div align="center">
                  <?= $key+1 ?>
                </div></td>
                <td width="163"><b><?= utf8_encode($tipoDoc->getTipoDocDesc()) ?></b></td>
                <td width="384"><div align="left">Descri&ccedil;&atilde;o: 
                    <input type="text" id="descricaoDocGeral<?= @$valueDoc->getDocumentoId() ?>2" size="40" maxlength="40" value="<?= utf8_encode(@$valueDoc->getDocDescricao()) ?>" />
                </div></td>
                <td><div align="right">
                  <div align="left">Data Exp:
                    <input type="text" id="dataExpDocGeral<?= @$valueDoc->getDocumentoId() ?>3" class="datepicker" size="10" maxlength="10" value="<?= @$dtExp ?>" />
                  </div>
                </div></td>
              </tr>
              <tr>
                <td><div align="left">N&ordm;
                      <input type="text" id="nrDoc<?= @$valueDoc->getDocumentoId() ?>" size="15" maxlength="15" value="<?= @$nrDoc ?>" />
                </div></td>
                <td><div align="left">Expedidor:
                  <input type="text" id="expedidorDocGeral<?= @$valueDoc->getDocumentoId() ?>2" size="10" maxlength="10" value="<?= @$valueDoc->getEmissor() ?>" />
                                </div></td>
                <td width="159"><div align="left">UF: 
                  <select name="ufDocGeral<?= @$valueDoc->getDocumentoId() ?>" id="ufDocGeral<?= @$valueDoc->getDocumentoId() ?>">
                    <option value="<?= $valueDoc->getUfCod() ?>">
                    <?= $ufGrupo1->getUfSigla() ?>
                    </option>
                    <?php $this->load->view('uf/cbo_uf'); ?>
                  </select>
                </div></td>
    </tr>
    </table>
            
            
               
<?php
        } else if($tipoDoc->getGrupo() == 3){
        
?>
            
            <table width="790" border="1"  cellpadding="0" cellspacing="0" <?= $background?> >
              <tr class="expand_head" id="tr5_doc_<?= @$valueDoc->getDocumentoId();?>" >
                <td width="66"><div align="center">
                  <?= $key+1 ?>
                </div></td>
                <td width="163"><div align="left">
                  <div align="left"> <b>
                    <?= utf8_encode(@$tipoDoc->getTipoDocDesc()) ?>
                  </b> </div>
                </div></td>
                <td width="543">Descri&ccedil;&atilde;o:
                <input type="text" id="descricaoOutroDoc<?= @$valueDoc->getDocumentoId() ?>" size="40" maxlength="40" value="<?= utf8_encode(@$valueDoc->getDocDescricao()) ?>" /></td>
                </table>
         
              <?php
        }
}

?>
 </fieldset> 
</div>
</form>
<script>
    $(document).ready(function() {
        
        $('#btnUploadArquivo').click(function(){
            
            var fotoAluno = jQuery('input[id="fotoAluno"]').val();
            //var alunoId = jQuery('input[id="alunoId"]').val();

            jQuery.ajax( {
                    type: "POST",
                    url: '?c=c_documentacao&m=gravarFoto',
                    cache: false,
                    data: {
                        fotoAluno:fotoAluno
                    },
                    beforeSend: function (){
                        $('#div_body').addClass("div_carregando");
                    },
                    complete:  function(){
                        $('#div_body').removeClass("div_carregando");
                    },
                    success: function(data){

                        alert(data);
                    }    
                });
        });
    });
</script>
